package com.wanggsx.maindemo

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.Toast
import com.wanggsx.pluginlib.PluginManager
import com.wanggsx.pluginlib.ProxyActivity

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        PluginManager.getInstance().init(this)
        findViewById<Button>(R.id.btnToLoadApk_main_activity).setOnClickListener(
            View.OnClickListener {
                //加载apk文件
                var apkpath: String = Utils.copyAssetFileToAppCacheDir(MainActivity@this,"pluginapp.apk")
                PluginManager.getInstance().loadApk(apkpath)
                //打开activity
                var intent = Intent(MainActivity@ this, ProxyActivity::class.java)
                intent.putExtra("CLASSNAME", "com.wanggsx.plugindemo.MainActivity")
                startActivity(intent)
            }
        )
    }
}
